<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        body{
            background: #ccc;
        }
        .wrap{
            width: 300px;
            height: 500px;
            background: #fff;
            margin: 30px auto;
        }
        .wrap .tit{
            width: 270px;
            height: 30px;
            font-size: 12px;
            padding: 0 15px;
            margin-top: 20px;
            float: left;
            line-height: 30px;
        }
        .tit b{
            display: block;
            float: left;
        }
        .tit span{
            display: block;
            float: right;
            color: skyblue;
        }
        .box{
            width: 300px;
            height: 400px;
        }
        #username{
            width: 270px;
            height: 30px;
            margin-left: 15px;
        }
        #password{
            width: 250px;
            height: 30px;
            margin-left: 15px;
            margin-top: 5px;
            padding-left: 20px;
        }
        .box .check{
            width: 270px;
            height: 14px;
            padding: 12px 15px;
            font-size: 12px;
        }
        .check span{
            float: right;
        }
        #login{
            width: 270px;
            height: 30px;
            margin-left: 15px;
            background: red;
            color: #fff;
            outline: none;
            border: none;
            cursor: pointer;
            user-select: none;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <p class="tit">
            <b>1号店用户登录</b>
            <span>注册新账号</span>
        </p>
        <div class="box">
            <input type="text" id="username">
            <input type="password" placeholder="密码" id="password">
            <p class="check">
                <input type="checkbox" name="" id="">自动登录
                <span>忘记密码?</span>
            </p>
            <button id="login">登录</button>
        </div>
    </div>
</body>
<script>
    // var login = document.querySelector('.login');
    login.onclick = function() 
    {
        let xhr = new XMLHttpRequest();
        xhr.open('GET',`/login?username=${username.value}&password=${password.value}`);
        xhr.send();
        xhr.onreadystatechange = function()
        {
            if(xhr.readyState == 4 && xhr.status == 200)
            {
                alert(xhr.responseText);
            }
        }
    }
</script>
</html>